<extend name="Public/base" />
<block name="content">
<div id="content" style="min-width:800px;">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	
	<div class="container-fluid search-form">
			<form class="m-filter" autocomplete="off">
				<div class="clearfix">
					<a class="pull-left btn btn-success btn-filter-show" id="j-filter-show"><span class="icon-chevron-down"></span></a>
				</div>
				
				<div class="filter-box" id="j-filter-box">
					<!-- 基础信息 -->
					<div class="filter-base filter-group">
						<a class="title"><span class="icon-list"></span> 基础信息</a>
						<span class="control-group">
							<select class="form-control" style="width: 150px;" name="activity_id" id="activity_id" onchange="change_merchant(activity_id, '{:U('Shop/getActivityMerchant')}')">
								<option value=0>选择活动</option>
								<volist name="activity_list" id="vo">
									<option value='{$vo.activity_id}'>{$vo.activity_name|strip_tags}</option>
								</volist>
								{$Think.config.ACTIVITY_TTTM}
							</select>
						</span>
						<span class="control-group">
							<select class="form-control" style="width: 180px;" name="merchant_id" id="merchant_id" onchange="change_shop(activity_id,merchant_id, '{:U('Shop/getMerchantShop')}')">
								<option value=0>选择商户</option>
								<volist name="merchant_list" id="vo">
									<option value='{$vo.merchant_id}'>{$vo.merchant_name|strip_tags}</option>
								</volist>
							</select>
						</span>
						<span class="control-group">
							<select class="form-control" style="width: 150px;" name="shop_id" id="shop_id">
								<option value=0>选择店铺</option>
								<volist name="shop_list" id="vo">
									<option value='{$vo.shop_id}'>{$vo.shop_name|strip_tags}</option>
								</volist>
							</select>
						</span>
					</div>
				
					<!-- 手机&订单号 -->
					<div class="filter-input filter-group clearfix">
						<a class="title"><span class="icon-globe"></span> 手机号&订单号</a>
					  	<div class="control-group pull-left">
					    	<div class="controls">
								<input type="text" name="phone_number" value="{:strip_tags(I('phone_number'))}" placeholder="手机号" class="search-input" maxlength="11" onkeyup="value=value.replace(/[a-zA-z]+$/,'')">
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
								<input type="text" name="paper_order" value="{:strip_tags(I('paper_order'))}" placeholder="纸质订单号" class="search-input" maxlength="13" onkeyup="value=value.replace(/[a-zA-z]+$/,'')"> 
					    	</div>
					  	</div>
					  	<div class="control-group pull-left" style="margin-left:15px;">
					    	<div class="controls">
								<input type="text" name="order_id" value="{:strip_tags(I('order_id'))}" placeholder="订单号" class="search-input" maxlength="13" onkeyup="value=value.replace(/[a-zA-z]+$/,'')"> 
					    	</div>
					  	</div>
					</div>
					<!-- /手机&订单号 -->
				
					<div class="clearfix btn-group">
						<a class="btn btn-success btn pull-left" id="j-filter-hide" style="margin-left:15px;"><span class="icon-chevron-up"></span></a>
						<button type="button" id="search_button" url="{:U('Order/applyRefund')}" class="btn btn-primary btn pull-left"><span class="icon-search"></span></button>
					</div>	
				</div>		
			</form>
		</div>
	
	
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content">
						<notempty name="_list">
							<table class="table table-bordered table-striped">
								<thead>
									<tr>
										<th nowrap="nowrap">序号</th>
										<th nowrap="nowrap">订单</th>
										<th nowrap="nowrap">纸质订单</th>
										<th>店铺</th>
										<th>品类</th>
										<th>金额</th>
										<th>支付方式</th>
										<th>商户单号</th>
										<th>手机号</th>
										<th>下单时间</th>
										<th>状态</th>
										<th>补打</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<volist name="_list" id="vo">
										<tr>
											<td style="height:23px;" class="taskStatus">{$i}</td>
											<td nowrap="nowrap" class="taskStatus"><a style="color:#49afcd;" href="{:U('orderInfo?order_id='.$vo['order_id'])}">{$vo.order_id}</a></td>
											<td nowrap="nowrap" class="taskStatus"><a style="color:#49afcd;" href="{:U('orderInfo?order_id='.$vo['order_id'])}">{$vo.paper_order}</a></td>
											<td class="taskStatus" title="{$vo.shop_name|htmlspecialchars}">{$vo.shop_name|htmlspecialchars|msubstr=###,0,20}</td>
											<td class="taskStatus">{$vo.conf_category_id|getConfCategoryName}</td>
											<td class="taskStatus">{$vo.amount}</td>
											<td nowrap="nowrap" class="taskStatus">{$vo.pay_type|get_pay_title}</td>
											<td class="taskStatus">{$vo.server_order_id|default='-'|htmlspecialchars}</td>
											<td class="taskStatus">{$vo.customer_id|getCustomerName}</td>
											<td class="taskStatus">{$vo.create_time|time_format}</td>
											<td nowrap="nowrap" class="taskStatus">{$vo.order_status|get_type_title}</td>
											<td class="taskStatus" nowrap="nowrap" ><button class="btn btn-mini btn-warning" onclick="pay_print('{$vo.payment_id}')">打印（补）</button></td>
											<td nowrap="nowrap" class="taskStatus">
											<a href="javascript:void(0);"  class="confirm btn btn-danger btn-mini" onclick="order_refund('{$vo.order_id}','{$vo.payment_id}');">退 款</a>
											</td>
										</tr>
									</volist>
								</tbody>
							</table>
							<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers" id="DataTables_Table_0_paginate">
								{$_page}
							</div>
						<else/>
							<center>请根据搜索条件进行查询</center>
						</notempty>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
//补打凭证
function pay_print(payment_id){
	if(payment_id == 0){
		return false;
	}
	window.open("__APP__/Order/printSupply/payment_id/" + payment_id + "/status/1" ,"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes");
}
//退款操作
function order_refund(order_id,payment_id){
	if(!confirm('是否进行退款操作？')){
		return false;
	}
	$.post("{:U('Order/refund')}", { order_id : order_id , payment_id : payment_id }, call_back, "json");
	return false;
	/**
	 * @todo 接收登录返回值
	 * @author PHP@妖孽 <dino_ma@163.com>
	 */
	function call_back(data){
		if(data.status==1){
			tke_alert(data.info, 'alert-success', 2000);
			setTimeout(function() {
				location.reload();
            }, 2000);
		} else {
			$('button').attr('disabled', false);
			tke_alert(data.info, 'alert-error', 2000);
		}
	}
}
$(function (){
	//日期控件
	$(".datepicker").datetimepicker({
		format: 'yyyy-mm-dd hh:ii', 
	    autoclose: true,
	    todayBtn: true
	});
	//条件框
	$("#j-filter-hide").click(function(){
		$("#j-filter-box").fadeOut(300);
		$("#j-filter-show").fadeIn(300);
	});
	$("#j-filter-show").click(function(){
		$("#j-filter-box").fadeIn(300);
		$(this).fadeOut(300);
	});
	
	set_value("activity_id",'{:I('activity_id')}')
	set_value("merchant_id",'{:I('merchant_id')}')
	set_value("shop_id",'{:I('shop_id')}')
	set_value("order_type",'{:I('order_type')}')
	set_value("order_status",'{:I('order_status')}')
	
	//默认活动
	if("0" != "{:C('JJHH_ACTIVITY_ID')}" && "{:I('activity_id')}"==0){
		set_value('activity_id', "{:C('JJHH_ACTIVITY_ID')}");
		change_merchant(activity_id, "{:U('Shop/getActivityMerchant')}");
	}
});
//导航高亮
highlight_subnav("{:U('Order/applyRefund')}");
</script>
</block>